/*
 * GLanguage.java
 * Created on 21 juin 2009
 *
 * VirtualHockey Internet Platform
 * http://code.google.com/p/virtualhockey/
 *
 * Copyright (c) 2005-2009, Jens and Jan Janke (VirtualHockey Project)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hockeo.vhbase.data.dao.misc;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import com.hockeo.vhbase.data.dao.IGEntity;

/**
 * Represents a language (used in conjunction w. GTranslation).
 *
 * @version $Id$
 * @author janjanke
 */
@Entity
@Table( name = "m_language" )
public class GLanguage implements IGEntity
{
  @Id
  @Column( name = "id" )
  private String  d_strId;

  @Column( name = "default" )
  private boolean d_fDefault;

  /** Default no argument constructor. */
  protected GLanguage()
  {}

  public String getId()
  {
    return d_strId;
  }

  public boolean isDefault()
  {
    return d_fDefault;
  }

  public Class<? extends IGEntity> getGEntityClass()
  {
    return GLanguage.class;
  }

  public boolean instanceOf( Class<? extends IGEntity> classOther )
  {
    return classOther.isAssignableFrom( getGEntityClass() );
  }

  /*
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals( Object obj )
  {
    try
    {
      return d_strId.equals( ( (GLanguage) obj ).getId() );
    }
    catch ( Exception ex ) // especially ClassCastException(s) may happen
    {
      return false;
    }
  }

  /*
   * @see java.lang.Object#hashCode()
   */
  @Override
  public int hashCode()
  {
    return d_strId.hashCode();
  }

  /*
   * @see java.lang.Object#toString()
   */
  @Override
  public String toString()
  {
    return d_strId;
  }
}
